#!/usr/bin/env ruby

def check_md5 file_path
  result = `md5sum -c #{file_path}.md5`
  result = /\: OK/m.match(result) ? "success":"fail" 
  `touch #{file_path}.md5.#{result}` 
end

#puts "[#{Time.new}] Start"
Dir.chdir 'home/zeropage/backup/'
Dir["*.tgz"].each do |n|
  check_md5 n if Dir["#{n}.md5.*"].empty?
end
#puts "[#{Time.new}] End"
